package com.helloae.jmx;

import java.lang.management.ManagementFactory;

import javax.management.InstanceAlreadyExistsException;
import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;

import com.sun.jdmk.comm.HtmlAdaptorServer;

public class Main {

	public static void main(String[] args) throws MalformedObjectNameException, NullPointerException, InstanceAlreadyExistsException, MBeanRegistrationException, NotCompliantMBeanException {
		MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
		final HtmlAdaptorServer htmlAdaptor = new HtmlAdaptorServer();
		final ObjectName htmlAdaptorON = new ObjectName("com.example.mbeans:name=HtmlAdaptor");
		mbs.registerMBean(htmlAdaptor, htmlAdaptorON);
		htmlAdaptor.setPort(9999);
		
		System.out.println("Staring the HtmlAdaptor...");
		htmlAdaptor.start();
	}

}
